package com.jxpanda.infrastructure.core.formatter;

import lombok.RequiredArgsConstructor;

import java.math.BigDecimal;
import java.text.DecimalFormat;

@RequiredArgsConstructor
public enum DecimalFormatter {


    /**
     * 小数点后2位
     */
    TWO_DECIMAL("#.00");
    private final DecimalFormat formatter;

    DecimalFormatter(String pattern) {
        this.formatter = new DecimalFormat(pattern);
    }

    public String format(double number) {
        return formatter.format(number);
    }

    public String format(BigDecimal number) {
        return formatter.format(number);
    }

}
